#ifndef ENGINE_GAME_H
#define ENGINE_GAME_H
#include "apoget.h"
#include <Support\Timing\Clock.h>
#include <Support\Graphics\Graphics.h>

class String;
class Console;
class MessageDialog;
class TextDX;
class  POGET_API Game
{
	bool quietMode;

	Timing::Clock clock;

	HWND hwnd; // Window handle
	HRESULT hr; // Standard return type
	float frameTime; // Time required for last frame
	float fps; // Frames per second
	bool    fpsOn;                  // true to display fps
	TextDX  *dxFont;                 // DirectX font for fps
	DWORD sleepTime; // Milliseconds to sleep between frames
	bool paused; // True if game is paused
	bool initialized;
	MessageDialog *messageDialog;
	Console *console; // Pointer to Console
	String* command;

public:
	Game();
	virtual ~Game();

	// Initialize the game
	// Pre: hwnd is handle to window
	virtual bool initialize(HWND hw = NULL, const char* configurationFile = nullptr,
		bool quiet = true);
	bool shutdown();
	void terminate(int terminationCode = -1);

	LRESULT messageHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
		lParam);

	// Call run repeatedly by the main message loop in WinMain
	virtual void run(HWND);
	// Call when the graphics device was lost
	// Release all reserved video memory so graphics device may be reset
	virtual void releaseAll();
	// Recreate all surfaces and reset all entities
	virtual void resetAll();
	// Delete all reserved memory
	virtual void deleteAll();
	// Render game items
	virtual void renderGame();
	// Handle lost graphics device
	virtual void handleLostGraphicsDevice();
	// Return pointer to Graphics
	//Graphics* getGraphics() { return graphics; }
	// Return pointer to Input
	//Input* getInput() { return input; }
	// Exit the game
	void exitGame() { PostMessage(hwnd, WM_DESTROY, 0, 0); }
	// Pure virtual function declarations
	// These functions MUST be written in any class that inherits from Game
	// Update game items.
	virtual void update() = 0;
	// Perform AI calculations
	virtual void ai() = 0;
	// Check for collisions
	virtual void collisions() = 0;
	// Render graphics
	// Call graphics->spriteBegin();
	// draw sprites
	// Call graphics->spriteEnd();
	// draw non-sprites
	virtual void render() = 0;

	void consoleCommand();

	// Set display mode (fullscreen, window or toggle)
	void setDisplayMode(graphicsNS::DISPLAY_MODE mode = graphicsNS::TOGGLE);




};

#endif